package com.yj.springbootjava8.stream;

import lombok.Data;

import java.util.Optional;

@Data
class Person {
    private String name; // 姓名
    private int salary; // 薪资
    private int age; // 年龄
    private String sex; //性别
    private String area; // 地区

    // 构造方法
    public Person(String name, int salary, int age,String sex,String area) {
        this.name = name;
        this.salary = salary;
        this.age = age;
        this.sex = sex;
        this.area = area;
    }
    // 省略了get和set，请自行添加

    public static void main(String[] args) {
        Person person = new Person(null, 100, 22, null, null);

        Optional.ofNullable(person).map(Person::getName).orElseGet(() -> {return null;});
        Optional.ofNullable(person).map(Person::getName).orElseGet(() -> {return null;});

    }

}